﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="xgmrts.aspx.cs" Inherits="morning_xgmrts" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.3.2.min.js" language="javascript" type="text/javascript"></script>
    <link href="../css/jquery-ui-1.7.3.custom.css" rel="Stylesheet" type="text/css" />
    <script src="../js/jquery-ui-1.7.3.custom.min.js" language="javascript" type="text/javascript"></script>
    <script>
        $(document).ready(function () {
            $('#dialog').dialog({
                autoOpen: false,
                modal: true,
                width: 550,
                buttons: {
                    "取消": function () {
                        var czjy = $("#txtCzjy").val("");
                        var sgjy = $("#txtSgjy").val("");
                        $(this).dialog("close");
                    },
                    "确定": function () {
                        var czjy = encodeURI( $("#txtCzjy").val());
                        var sgjy = encodeURI( $("#txtSgjy").val());
                        if (czjy == "") {
                            alert("操作建议不能为空");
                            return;
                        }
                        if (sgjy == "申购建议") {
                            alert("申购建议不能为空");
                            return;
                        }
                        if (flag == "add") {
                            $.post("handler/xgmrts.ashx", { flag: "add", ctime: cTime, czjy: czjy, sgjy: sgjy }, function (data) {
                                if (data == "1") {
                                    alert("添加成功");
                                    document.location = document.location;
                                }
                                else {
                                    alert("添加失败");
                                }
                            })
                        }
                        else if (flag == "edit") {
                            $.post("handler/xgmrts.ashx", { flag: "edit", id: id, czjy: czjy, sgjy: sgjy }, function (data) {
                                if (data == "1") {
                                    alert("修改成功");
                                    document.location = document.location;
                                }
                                else {
                                    alert("修改失败");
                                }
                            })
                        }
                        var czjy = $("#txtCzjy").val("");
                        var sgjy = $("#txtSgjy").val("");
                    }
                }
            });

            var cTime, id, flag;
            $("[IsAdd=true]").click(function () {
                flag = "add";
                cTime = $(this).attr("ctime");
                $('#dialog').dialog("open");
                return false;
            })

            $("[IsEdit=true]").click(function () {
                id = $(this).attr("tid");
                $.post("handler/xgmrts.ashx", { flag: "get", id: id }, function (data) {
                    var c = eval("(" + data + ")");
                    $("#txtCzjy").val(c.czjy);
                    $("#txtSgjy").val(c.sgjy);
                    flag = "edit";
                    $('#dialog').dialog("open");
                })
                return false;
            })

            $("[IsDelete=true]").click(function () {
                if (confirm("是否删除?")) {
                    id = $(this).attr("tid");
                    $.post("handler/xgmrts.ashx", { flag: "del", id: id }, function (data) {
                        if (data == "1") {
                            alert("删除成功");
                            document.location = document.location;
                        }
                    })
                }
                return false;
            })
        })
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC" 
            BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest" 
            Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="319px" 
            ondayrender="Calendar1_DayRender" ShowGridLines="True" Width="736px">
            <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
            <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
            <OtherMonthDayStyle ForeColor="#CC9966" />
            <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
            <SelectorStyle BackColor="#FFCC66" />
            <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" 
                ForeColor="#FFFFCC" />
            <TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
        </asp:Calendar>
    
    </div>
    <br />
     <div class="button_bar">
        <asp:Button ID="btnQuery" CssClass="common_button" runat="server" Text="查询" 
             onclick="btnQuery_Click"   />
    </div>
    <div>
          <table class="query_form_table" style="width:500px">
            <tr>
                <th>查询条件</th>
                <td> <asp:TextBox ID="txtQuery" runat="server" Width="187px"></asp:TextBox></td>
            </tr>
          </table>
            <table class="data_list_table">
                <tr>
                    <th>
                        编号
                    </th>
                    <th>
                        日期
                    </th>
                    <th>
                        操作建议
                    </th>
                    <th>
                        申购建议
                    </th>
                </tr>
                      <asp:Repeater ID="Repeater1" runat="server">
                <ItemTemplate>
                    <tr>
                        <td class="list_data_text">
                            <%# Eval("id")%>
                        </td>                                               
                        <td class="list_data_text">
                            <%# Eval("CTime","{0:yyyy-MM-dd}")%>
                        </td>                        
                        <td class="list_data_text">
                            <%# Eval("czjy")%>
                        </td>
                        <td class="list_data_text">
                            <%# Eval("sgjy")%>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
            </table>
          
    </div>
  
    <div id="dialog" title="提示消息">
        <table class="query_form_table" style="width:500px">
           
            <tr>
                <th style="width:60px">
                    操作建议
                </th>
                <td colspan="3">
                    <asp:TextBox ID="txtCzjy" runat="server" Height="68px" TextMode="MultiLine" 
                        Width="400px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th style="width:60px">申购建议</th>
                <td colspan="3">
                    <asp:TextBox ID="txtSgjy" runat="server" Height="81px" TextMode="MultiLine" 
                        Width="400px"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
      </form>
</body>
</html>
